package utils;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.xyz.musicplayer.R;

import java.util.List;

import beans.Songer;

public class SongerAdapter extends ArrayAdapter<Songer> {


    public SongerAdapter(@NonNull Context context, int resource, @NonNull Songer[] objects) {
        super(context, resource, objects);
    }

    public SongerAdapter(@NonNull Context context, int resource, @NonNull List<Songer> objects) {
        super(context, resource, objects);
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        Songer songer = getItem(position);

        View view = LayoutInflater.from(getContext()).inflate(R.layout.history_item,parent,false);

        //获取指定布局控件实例
        ImageView iv = (ImageView) view.findViewById(R.id.iv_history);
        TextView tvForSong = (TextView) view.findViewById(R.id.tv_songname);
        TextView tvForSonger = (TextView) view.findViewById(R.id.tv_songername);

        //对控件进行操作
        tvForSong.setText(songer.getSong());
        tvForSong.setTextSize(20);
        tvForSong.setTextColor(Color.RED);
        tvForSonger.setText(songer.getSonger());
        tvForSonger.setTextSize(20);
        tvForSonger.setTextColor(Color.RED);

        return view;
    }


}
